package net.lainiao.morethread.Chapter5.demo5;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/6.
 */
public class Main {
    public static void main(String[] args) {
        ArrayGenerator generator=new ArrayGenerator();
        int array[]=generator.generateArray(1000);
        TaskManager taskManager=new TaskManager();
        ForkJoinPool pool=new ForkJoinPool();
        SearchNumberTask task=new SearchNumberTask(array,0,1000,7,taskManager);
        pool.execute(task);
        pool.shutdown();
        try {
            pool.awaitTermination(1, TimeUnit.DAYS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Main : The program has finished "+taskManager.getResult());
    }
}
